﻿<%@ Page Title="" Language="C#" MasterPageFile="../Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<SailHero.Soft.FrameWork.Models.SYS_USER>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    用户列表
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        //Gridview CheckBox全选
        $(function () {
            $("#chkAll").click(function () {
                var flag = $(this).attr("checked");
                if (flag == "checked") {
                    $("[name=CheckBoxSelect]:checkbox").each(function () {
                        $(this).attr("checked", flag);
                    });
                }
                else {
                    $("[name=CheckBoxSelect]:checkbox").each(function () {
                        $(this).attr("checked", false);
                    });

                }
            });
            //取消全选
            $("[name=CheckBoxSelect]").click(function () {
                $("#chkAll").attr("checked", false);
            });

            $("#edit").click(function () {
                var obj = $("[name=CheckBoxSelect]:checked");
                if (obj.length == 0) {
                    $.messager.alert("提示信息", "请选择编辑项！", "info");
                }
                else if (obj.size() > 1) {
                    $.messager.alert("提示信息", "一次只能编辑一项！", "info");
                }
                else {
                    obj.each(function () {
                        var value = $(this).val();
                        location.href = "/User/Edit/?ID=" + value;
                    });
                }
            });

            $("#delete").click(function () {

                var obj = $("[name=CheckBoxSelect]:checked");
                if (obj.length == 0) {
                    $.messager.alert("提示信息", "请选择删除项！", "info");
                }
                else {
                    var select = "";
                    obj.each(function () {
                        select += ";" + $(this).val();
                    });
                    $.messager.confirm("提示信息", "确定要删除选中的【" + obj.length + "】项：", function (r) {
                        if (r) {
                            var url = "/User/Delete";
                            $.post(url, {
                                id: select
                            },
                function (data) {
                    if (data == "success") {
                        //                        $.messager.alert("提示信息", "删除成功", "info");
                        window.location.href = "/User/Index";

                        //alert("aa");
                    }
                    else {
                        $.messager.alert("错误信息", data, "error");
                    }
                });
                        }
                    });
                }
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="TabTitle" runat="Server">
    用户管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
        <tr>
            <td>
                <table style="width: 100%; margin-top: 5px;" cellpadding="0" cellspacing="0">
                    <caption class="tcaption">
                        <table style="width: 100%;" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td align="left">
                                    <table class="tableTitle">
                                        <tr>
                                            <td width="80px">
                                                <span style="color: Green; font-weight: bold; padding-left: 5px;">用户列表</span>
                                            </td>
                                            <td width="50px">
                                                <a href="/User/Create" class="operateA">
                                                    <img style="vertical-align: middle; border: 0;" src="<%=Page.ResolveUrl("../../content/images/add.png")%>"
                                                        alt="新增" />&nbsp;新增</a>
                                            </td>
                                            <td width="50px">
                                                <a id="edit">
                                                    <img style="vertical-align: middle" src="<%=Page.ResolveUrl("../../content/images/edit2.png")%>" alt="修改" />&nbsp;编辑</a>
                                            </td>
                                            <td width="50px">
                                                <a id="delete">
                                                    <img style="vertical-align: middle" src="<%=Page.ResolveUrl("../../content/images/delete.png")%>" alt="删除" />&nbsp;删除</a>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                        </table>
                    </caption>
                    <tr>
                        <td>
                            <table class="mytable" cellspacing="0" rules="all" border="1" style="width: 100%;
                                border-collapse: collapse;">
                                <tr>
                                    <th>
                                        NO.
                                    </th>
                                    <th>
                                        <input id="chkAll" type="checkbox" />
                                    </th>
                                    <th>
                                        帐号
                                    </th>
                                    <th>
                                        姓名
                                    </th>
                                    <th>
                                        部门
                                    </th>
                                    <th>
                                        电话
                                    </th>
                                    <th>
                                        移动电话
                                    </th>
                                    <th>
                                        邮箱
                                    </th>
                                    <th>
                                        工号
                                    </th>
                                    <th>
                                        性别
                                    </th>
                                    <th>
                                        生日
                                    </th>
                                    <th>
                                        状态
                                    </th>
                                </tr>
                                <% int num = 0; //编号


                                   foreach (var item in Model)
                                   {
                                       num += 1; %>
                                <tr>
                                    <td align="center" style="width: 30px;">
                                        <%:num %>
                                    </td>
                                    <td align="center" style="width: 30px;">
                                        <input id="CheckBoxSelect" name="CheckBoxSelect" value="<%: item.USERID %>" type="checkbox" />
                                    </td>
                                    <td align="center" style="width: 10%;">
                                        <%: item.ACCOUNT %>
                                    </td>
                                    <td align="center" style="width: 10%;">
                                        <%: item.USERCNAME %>
                                    </td>
                                    <td align="center">
                                    </td>
                                    <td align="center">
                                        <%: item.MOBILE %>
                                    </td>
                                    <td align="center">
                                        <%: item.TELEPHONE %>
                                    </td>
                                    <td align="center">
                                        <%: item.EMAIL %>
                                    </td>
                                    <td align="center">
                                        <%: item.JOBNUMBER %>
                                    </td>
                                    <td align="center">
                                        <%: item.SEX.ToString() == "0" ? "女" : "男"%>
                                    </td>
                                    <td align="center">
                                        <%: string.IsNullOrEmpty(item.BIRTHDAY) ? "" : Convert.ToDateTime(item.BIRTHDAY.ToString()).ToString("MM-dd")%>
                                    </td>
                                    <td align="center">
                                        <%if (item.ISENABLE=="1")
                                          { %>
                                        可用
                                        <%}
                                          else
                                          {%>
                                        <font color="red">禁用</font>
                                        <%} %>
                                        <%--   <%: item.IsEnable.ToString() == "True" ? "可用" : "禁用"%></td>--%>
                                </tr>
                                <%} %>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td class="page2">
                            <%=ViewData["page"] %>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>
